#include <iostream>

#include "command.hpp"

int main()
{
    key_t key = Get_key();

    int shmid = GetShm(key);

    // 挂接
    char *s = (char *)shmat(shmid, nullptr, 0);
    std::cout << "attach shm done" << std::endl;

    int fd = open(filename.c_str(), O_WRONLY);
    char c = 'a';
    for (; c <= 'z'; c++)
    {
        s[c - 'a'] = c;
        std::cout << "write : " << c << " done" << std::endl;
        sleep(1);
        int code;
        write(fd, &code, sizeof(code));
    }

    shmdt(s);
    std::cout << "detach shm done" << std::endl;
    close(fd);

    return 0;
}
